<script type="text/javascript" src="/js/prototype.js"></script>
 <script type="text/javascript" src="/js/DatePicker/WdatePicker.js" ></script>
<div class="row">
 <small>
  <div class="span12">
   <div class="clearfix txtleft search" style="background-color:#f8f8f8; padding:10px; margin:10px 0px;"> 
      <form action="/<*$controller*>/student" method="get" class="form-horizontal" name="form1">       
		  机构:<select id="jigou" name="groups"  onchange="getSchool(this.value)"></select>
          校园:<select id="school" name="school"  onchange="getClass(this.value)"></select> 
          班级:<select id="class1" name="class" ></select>   
         <input type="submit" class="btn btn-success"  value="查询"  >
         <input type="button" class="btn btn-success" value="清空查询" onclick="window.location='/<*$controller*>/index'" >
        
      </form>
	</div> 
  	<div class="table_content"> 
    <form action="/<*$controller*>/add" method="post" class="form-horizontal" name="form">
     <*if $result|@count neq 0*>  
   <table cellpadding="0" cellspacing="0" class="table">
		 <tr> 
		   <th class="span12" colspan="11"><b>总数：<*$result|count*></b>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:red" >注：没有家长的学生从mtest删除！</span></th> 
		</tr> 
        <tr> 
			<th class="span2">姓名</th>
			<th class="span2">教师端昵称</th>
            <th class="span2">家长姓名</th>  
            <th class="span1">家长账号</th>  
              <th class="span1">家长密码</th>  
            <th class="span2">手机号</th>  
            <th class="span2">家长端昵称</th>	
            <th  class="span2">生日</th> 
            <th  class="span3">性别</th> 
            <th  class="span3">操作</th>
			<th>&nbsp;</th>
		</tr>
          
    <*foreach from=$result item=a key =key name=foo*>
		<tr>
			<td><input type="text" value="<*$a.cnname*>" name="cnname[]" class="input-small" /></td>
			<td><input type="text" value="<*$a.enname*>" name="enname[]"  class="input-small" /></td>
            <td><input type="text" name="realname[]" value="<*$a.realname*>" class="input-small" /></td>
             <td><*$a.username*></td>
             <td><*$a.password*></td>
            <td><input type="text" value="<*$a.mobile*>" name="mobile[]" class="input-small" /></td>
            <td><input type="text" value="<*$a.nikename*>" name="nikename[]"  class="input-small" /></td>
			<td>  
              <input type="text" name="birthday[]" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="<*$a.birthday*>" class="input-small" > 
             </td>
			<td> <label class="radio inline"> 
               <input type="radio" name="sex[<*$smarty.foreach.foo.index*>]" id="sex[<*$smarty.foreach.foo.iteration *>]"   value="1"  <*if $a.sex eq 1*> checked <*/if*>> 男 
               </label>
               <label class="radio inline"> 
               <input type="radio" name="sex[<*$smarty.foreach.foo.index*>]" id="sex[<*$smarty.foreach.foo.iteration *>]"  value="2"  <*if $a.sex eq 2*> checked <*/if*>> 女
                </label>
                 <input type="hidden" name="stu_id[]"  value="<*$a.studentid*>" />
                 <input type="hidden" name="stu_uid[]"  value="<*$a.stuid*>" />  
                  <input type="hidden" name="pid[]"  value="<*$a.pid*>" />
                  <input type="hidden" name="class_uid"  value="<*$a.class_uid*>" /> 
                  <input type="hidden" name="username[]"  value="<*$a.username*>" />
                  <input type="hidden" name="password[]"  value="<*$a.password*>" />
             </td> 
            <td> 
            <*if $a.pid*>
            <a role="button" class="btn" data-toggle="modal" onclick="javascript:deleteit('<*$a.studentid*>','<*$a.uid*>', '<*$a.classid*>','<*$groups*>','<*$school_id*>','<*$classid*>','<*$a.pid*>')"><i class="icon-remove"> </i> 删除</a> <*else*><*/if*>  
            </td>
            <td>&nbsp;</td>
		</tr>  
		<*/foreach*>
        <tr> 
		   <th class="span12" colspan="11"><b>总数：<*$result|count*></b></th> 
		</tr>
<!--        <tr> 
		   <th class="span12" colspan="11">  
                <input type="button" class="btn btn-success" value="增加学生" onclick="window.location='/<*$controller*>/addstudent/groupid/<*$groupid*>/schoolid/<*$schoolid*>/classid/<*$classid*>'" >
           </th> 
		</tr>   
-->        
         <tr >
        	<td colspan="11" >
               <input type="hidden" name="groupid"  value="<*$groupid*>" />
               <input type="hidden" name="school_id"  value="<*$school_id*>" />
               <input type="hidden" name="schoolid"  value="<*$schoolid*>" />
                <input type="hidden" name="classid"  value="<*$classid*>" /> 
            
            <div class="form-actions text-left">
              <button type="submit" class="btn btn-large btn-block btn-primary">保存修改</button> 
            </div> 
            </td>
            <td>&nbsp;</td>
        </tr>
       <tr>
        	<td colspan="11"> <*$page*></td>
            <td>&nbsp;</td>
        </tr>
      <*else*>  
          <tr>
        	<td colspan="11"> 没有您要的结果,请改变你的搜索条件！</td>
            <td>&nbsp;</td>
        </tr> 
         <*/if*> 
        
        </table>  
       </form> 
        </div> 
    </div>
  </div>  
    </small> 
  
<script type="text/javascript"> 

  window.onload=function(){
	 jigou(); 

	if('<*$groups*>' != ''){
		getSchool('<*$groups*>');
	}
	if('<*$school_id*>' != ''){
		getClass('<*$school_id*>');
	}

 } 
function jigou()
{  

	var url     = '/<*$controller*>/groups/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '';
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_course});

} 
function showResponse_course(originalRequest)
{
	{  //alert(originalRequest.responseText);  
		 document.all.form1.groups.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		  if('<*$groups*>' != ''){
			 jsSelectIsExitItem(document.all.form1.groups,'<*$groups*>');
	        } 
	 }

}  

function getSchool(a)
{  
	var url  = '/<*$controller*>/schoollist/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '&id=' + a;
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_school});

} 
function showResponse_school(originalRequest)
{
	{    //alert(originalRequest.responseText);  
		 document.all.form1.school.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		  if('<*$school_id*>' != ''){
				jsSelectIsExitItem(document.all.form1.school,'<*$school_id*>');
			}
	 } 
}  
function getClass(a)
{  
     
	var url  = '/<*$controller*>/classlist/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '&id=' + a;
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_class});

} 
function showResponse_class(originalRequest)
{
	{    //alert(originalRequest.responseText);  
		 document.all.form1.class.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		  if('<*$classid*>' != ''){
				jsSelectIsExitItem(document.all.form1.class,'<*$classid*>');
			}
	 } 
}  
function deleteit(sid,stuid,clauid,groupid,schoolid,classid,pid)
{  
   

  if(confirm("删除将不能恢复")){
   window.location='/<*$controller*>/delete/sid/'+sid+'/stuid/'+stuid+'/clauid/'+clauid+'/groupid/'+groupid+'/schoolid/'+schoolid+'/classid/'+classid+'/pid/'+pid;
   }
} 
 
 function jsSelectIsExitItem(objSelect, objItemValue) {
	//alert(objSelect.options.length);
    for (var i = 0; i < objSelect.options.length; i++) {
        if (objSelect.options[i].value == objItemValue) { 
			objSelect.options[i].selected=true;
        	 break;
        }
    }
    return 1;
}  
 
 function addit(id){
	$(document).ready(function(){
	 //  $(".addnew").click(function(){ // Click to only happen on announce links
		 $("#account").val(id);
		 $('#myModal').modal('show');
	  // });
	});
				
} 
 
 
 
</script>
 </div> 